﻿using System;
using System.Data;
using Model;
using DBUtility;

namespace DAL
{
     /// <summary>
     /// 数据访问层RESULT_DOWNLINE_DAL
     /// </summary>
     public class RESULT_DOWNLINE_DAL
     {
         public RESULT_DOWNLINE_DAL()
         {
         }


         /// <summary>
         /// 得到最大JCLSH
         /// </summary>
         public string GetMax_JCLSH(string p_strWhere)
         {
             string strResult = "0";
             string strSql = "select max(JCLSH) as m from RESULT_DOWNLINE";

             if(p_strWhere.Trim().Length > 0)
             {
                 strSql += " where " + p_strWhere;
             }

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             if(dtTemp.Rows.Count>0)
             {
                 if(dtTemp.Rows[0]["m"].ToString().Length>0)
                 {
                     strResult = dtTemp.Rows[0]["m"] == DBNull.Value ? "" : dtTemp.Rows[0]["m"].ToString();
                 }
             }

             dtTemp.Dispose();

             return string.Format("{0:D50}", Convert.ToInt32(strResult) + 1);

          }

          /// <summary>
          /// 得到最大JCLSH
          /// </summary>
          public string GetMax_JCLSH()
          {
              return GetMax_JCLSH("");
          }


          /// <summary>
          /// 判断数据是否存在
          /// </summary>
          public bool Exists(string strJCLSH)
          {
               bool bolResult = false;

               if (strJCLSH == null)
               {
                   return false;
               }

               if (strJCLSH.Length == 0)
               {
                   return false;
               }

               string strSql = "";
               strSql += "select count(1) as c from RESULT_DOWNLINE";
               strSql += " where ";
               strSql += " JCLSH='"+ strJCLSH +"'";

               DataTable dtTemp = new DataTable();
               DbHelper.GetTable(strSql, ref dtTemp);

               if (dtTemp.Rows.Count > 0)
               {
                   bolResult = Convert.ToInt32(dtTemp.Rows[0]["c"]) > 0;
               }

               dtTemp.Dispose();

               return bolResult;

          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount(string p_strWhere)
          {
              int intResult=0;

              string strSql = "";
              strSql += "select count(1) as c from RESULT_DOWNLINE";
              if(p_strWhere.Trim().Length > 0)
              {
                 strSql += " where " + p_strWhere;
              }

              DataTable dtTemp = new DataTable();
              DbHelper.GetTable(strSql, ref dtTemp);

              if(dtTemp.Rows.Count>0)
              {
                  intResult=Convert.ToInt32(dtTemp.Rows[0]["c"]);
              }

              dtTemp.Dispose();

              return intResult;
          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount()
          {
              return GetRecordCount("");
          }

          /// <summary>
          /// 获取数据分页总数
           /// </summary>
          public int GetPageCount(string p_strWhere, int p_intPageSize)
          {
              int intResult=0;

              if(p_intPageSize > 0)
              {
                  int intRecordCount = GetRecordCount(p_strWhere);
                  intResult = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(intRecordCount) / Convert.ToDecimal(p_intPageSize)));
                  if (intRecordCount > (intResult * p_intPageSize))
                  {
                       intResult++;
                  }
              }

              if(intResult == 0)
              {
                   intResult++;
              }
              return intResult;
           }

          /// <summary>
          /// 获取数据分页总数
          /// </summary>
          public int GetPageCount(int p_intPageSize)
          {
              return GetPageCount("", p_intPageSize);
          }

          /// <summary>
          /// 添加一条数据 SQL
          /// </summary>
          public string InsertSQL(RESULT_DOWNLINE model)
          {
              string strFieldSQL = "";
              string strValueSQL = "";

              if(model.Changed("ID") == true)
              {
                   strFieldSQL += ",ID";
                   strValueSQL += "," + model.ID + "";
              }

              if(model.Changed("JCLSH") == true)
              {
                   strFieldSQL += ",JCLSH";
                   strValueSQL += ",'" + model.JCLSH.Replace("'","''") + "'";
              }

              if(model.Changed("WQLSH") == true)
              {
                   strFieldSQL += ",WQLSH";
                   strValueSQL += ",'" + model.WQLSH.Replace("'","''") + "'";
              }

              if(model.Changed("AJLSH") == true)
              {
                   strFieldSQL += ",AJLSH";
                   strValueSQL += ",'" + model.AJLSH.Replace("'","''") + "'";
              }

              if(model.Changed("ZJLSH") == true)
              {
                   strFieldSQL += ",ZJLSH";
                   strValueSQL += ",'" + model.ZJLSH.Replace("'","''") + "'";
              }

              if(model.Changed("MTLSH") == true)
              {
                   strFieldSQL += ",MTLSH";
                   strValueSQL += ",'" + model.MTLSH.Replace("'","''") + "'";
              }

              if(model.Changed("JCBGDBH01") == true)
              {
                   strFieldSQL += ",JCBGDBH01";
                   strValueSQL += ",'" + model.JCBGDBH01.Replace("'","''") + "'";
              }

              if(model.Changed("JCBGDBH02") == true)
              {
                   strFieldSQL += ",JCBGDBH02";
                   strValueSQL += ",'" + model.JCBGDBH02.Replace("'","''") + "'";
              }

              if(model.Changed("JCCS") == true)
              {
                   strFieldSQL += ",JCCS";
                   strValueSQL += ",'" + model.JCCS.Replace("'","''") + "'";
              }

              if(model.Changed("HPHM") == true)
              {
                   strFieldSQL += ",HPHM";
                   strValueSQL += ",'" + model.HPHM.Replace("'","''") + "'";
              }

              if(model.Changed("HPZL") == true)
              {
                   strFieldSQL += ",HPZL";
                   strValueSQL += ",'" + model.HPZL.Replace("'","''") + "'";
              }

              if(model.Changed("HPZLDH") == true)
              {
                   strFieldSQL += ",HPZLDH";
                   strValueSQL += ",'" + model.HPZLDH.Replace("'","''") + "'";
              }

              if(model.Changed("VIN") == true)
              {
                   strFieldSQL += ",VIN";
                   strValueSQL += ",'" + model.VIN.Replace("'","''") + "'";
              }

              if(model.Changed("CLZL") == true)
              {
                   strFieldSQL += ",CLZL";
                   strValueSQL += ",'" + model.CLZL.Replace("'","''") + "'";
              }

              if(model.Changed("CLZLDH") == true)
              {
                   strFieldSQL += ",CLZLDH";
                   strValueSQL += ",'" + model.CLZLDH.Replace("'","''") + "'";
              }

              if(model.Changed("JYLB") == true)
              {
                   strFieldSQL += ",JYLB";
                   strValueSQL += ",'" + model.JYLB.Replace("'","''") + "'";
              }

              if(model.Changed("JYLBDH") == true)
              {
                   strFieldSQL += ",JYLBDH";
                   strValueSQL += ",'" + model.JYLBDH.Replace("'","''") + "'";
              }

              if(model.Changed("YWLX") == true)
              {
                   strFieldSQL += ",YWLX";
                   strValueSQL += ",'" + model.YWLX.Replace("'","''") + "'";
              }

              if(model.Changed("ZYWLB") == true)
              {
                   strFieldSQL += ",ZYWLB";
                   strValueSQL += ",'" + model.ZYWLB.Replace("'","''") + "'";
              }

              if(model.Changed("ZYWLBDH") == true)
              {
                   strFieldSQL += ",ZYWLBDH";
                   strValueSQL += ",'" + model.ZYWLBDH.Replace("'","''") + "'";
              }

              if(model.Changed("SYR") == true)
              {
                   strFieldSQL += ",SYR";
                   strValueSQL += ",'" + model.SYR.Replace("'","''") + "'";
              }

              if(model.Changed("JCXH") == true)
              {
                   strFieldSQL += ",JCXH";
                   strValueSQL += "," + model.JCXH + "";
              }

              if(model.Changed("Z_PD") == true)
              {
                   strFieldSQL += ",Z_PD";
                   strValueSQL += ",'" + model.Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("AJ_Z_PD") == true)
              {
                   strFieldSQL += ",AJ_Z_PD";
                   strValueSQL += ",'" + model.AJ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("ZJ_Z_PD") == true)
              {
                   strFieldSQL += ",ZJ_Z_PD";
                   strValueSQL += ",'" + model.ZJ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("WQ_Z_PD") == true)
              {
                   strFieldSQL += ",WQ_Z_PD";
                   strValueSQL += ",'" + model.WQ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("QT_Z_PD") == true)
              {
                   strFieldSQL += ",QT_Z_PD";
                   strValueSQL += ",'" + model.QT_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("IsUpload") == true)
              {
                   strFieldSQL += ",IsUpload";
                   strValueSQL += "," + model.IsUpload + "";
              }

              if(model.Changed("IsAudit") == true)
              {
                   strFieldSQL += ",IsAudit";
                   strValueSQL += "," + model.IsAudit + "";
              }

              if(model.Changed("IsPrint") == true)
              {
                   strFieldSQL += ",IsPrint";
                   strValueSQL += "," + model.IsPrint + "";
              }

              if(model.Changed("DOWNLINEDATE") == true)
              {
                   strFieldSQL += ",DOWNLINEDATE";
                   strValueSQL += ",'" + model.DOWNLINEDATE.Replace("'","''") + "'";
              }

              if(model.Changed("JYLB_TYPE") == true)
              {
                   strFieldSQL += ",JYLB_TYPE";
                   strValueSQL += ",'" + model.JYLB_TYPE.Replace("'","''") + "'";
              }

              if(model.Changed("CLSXSJ") == true)
              {
                   strFieldSQL += ",CLSXSJ";
                   strValueSQL += ",'" + model.CLSXSJ.Replace("'","''") + "'";
              }

              if(model.Changed("YCY") == true)
              {
                   strFieldSQL += ",YCY";
                   strValueSQL += ",'" + model.YCY.Replace("'","''") + "'";
              }

              if(model.Changed("JCRQ") == true)
              {
                   strFieldSQL += ",JCRQ";
                   strValueSQL += ",'" + model.JCRQ.Replace("'","''") + "'";
              }

              string strSql = "";
              strSql += "insert into RESULT_DOWNLINE";
              strSql += "(";
              strSql += strFieldSQL.Substring(1);
              strSql += ")";
              strSql += " values";
              strSql += "(";
              strSql += strValueSQL.Substring(1);
              strSql += ")";

              return strSql;
          }

          /// <summary>
          /// 添加一条数据
          /// </summary>
          public bool Insert(RESULT_DOWNLINE model)
          {
              return DbHelper.ExecuteSql(InsertSQL(model));
          }

          /// <summary>
          /// 修改一条数据 SQL
          /// </summary>
          public string UpdateSQL(RESULT_DOWNLINE model,string strJCLSH)
          {
              string strUpdateSQL = "";

              if(model.Changed("ID") == true)
              {
                  strUpdateSQL += ",ID=" + model.ID + "";
              }

              if(model.Changed("JCLSH") == true)
              {
                  strUpdateSQL += ",JCLSH='" + model.JCLSH.Replace("'","''") + "'";
              }

              if(model.Changed("WQLSH") == true)
              {
                  strUpdateSQL += ",WQLSH='" + model.WQLSH.Replace("'","''") + "'";
              }

              if(model.Changed("AJLSH") == true)
              {
                  strUpdateSQL += ",AJLSH='" + model.AJLSH.Replace("'","''") + "'";
              }

              if(model.Changed("ZJLSH") == true)
              {
                  strUpdateSQL += ",ZJLSH='" + model.ZJLSH.Replace("'","''") + "'";
              }

              if(model.Changed("MTLSH") == true)
              {
                  strUpdateSQL += ",MTLSH='" + model.MTLSH.Replace("'","''") + "'";
              }

              if(model.Changed("JCBGDBH01") == true)
              {
                  strUpdateSQL += ",JCBGDBH01='" + model.JCBGDBH01.Replace("'","''") + "'";
              }

              if(model.Changed("JCBGDBH02") == true)
              {
                  strUpdateSQL += ",JCBGDBH02='" + model.JCBGDBH02.Replace("'","''") + "'";
              }

              if(model.Changed("JCCS") == true)
              {
                  strUpdateSQL += ",JCCS='" + model.JCCS.Replace("'","''") + "'";
              }

              if(model.Changed("HPHM") == true)
              {
                  strUpdateSQL += ",HPHM='" + model.HPHM.Replace("'","''") + "'";
              }

              if(model.Changed("HPZL") == true)
              {
                  strUpdateSQL += ",HPZL='" + model.HPZL.Replace("'","''") + "'";
              }

              if(model.Changed("HPZLDH") == true)
              {
                  strUpdateSQL += ",HPZLDH='" + model.HPZLDH.Replace("'","''") + "'";
              }

              if(model.Changed("VIN") == true)
              {
                  strUpdateSQL += ",VIN='" + model.VIN.Replace("'","''") + "'";
              }

              if(model.Changed("CLZL") == true)
              {
                  strUpdateSQL += ",CLZL='" + model.CLZL.Replace("'","''") + "'";
              }

              if(model.Changed("CLZLDH") == true)
              {
                  strUpdateSQL += ",CLZLDH='" + model.CLZLDH.Replace("'","''") + "'";
              }

              if(model.Changed("JYLB") == true)
              {
                  strUpdateSQL += ",JYLB='" + model.JYLB.Replace("'","''") + "'";
              }

              if(model.Changed("JYLBDH") == true)
              {
                  strUpdateSQL += ",JYLBDH='" + model.JYLBDH.Replace("'","''") + "'";
              }

              if(model.Changed("YWLX") == true)
              {
                  strUpdateSQL += ",YWLX='" + model.YWLX.Replace("'","''") + "'";
              }

              if(model.Changed("ZYWLB") == true)
              {
                  strUpdateSQL += ",ZYWLB='" + model.ZYWLB.Replace("'","''") + "'";
              }

              if(model.Changed("ZYWLBDH") == true)
              {
                  strUpdateSQL += ",ZYWLBDH='" + model.ZYWLBDH.Replace("'","''") + "'";
              }

              if(model.Changed("SYR") == true)
              {
                  strUpdateSQL += ",SYR='" + model.SYR.Replace("'","''") + "'";
              }

              if(model.Changed("JCXH") == true)
              {
                  strUpdateSQL += ",JCXH=" + model.JCXH + "";
              }

              if(model.Changed("Z_PD") == true)
              {
                  strUpdateSQL += ",Z_PD='" + model.Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("AJ_Z_PD") == true)
              {
                  strUpdateSQL += ",AJ_Z_PD='" + model.AJ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("ZJ_Z_PD") == true)
              {
                  strUpdateSQL += ",ZJ_Z_PD='" + model.ZJ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("WQ_Z_PD") == true)
              {
                  strUpdateSQL += ",WQ_Z_PD='" + model.WQ_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("QT_Z_PD") == true)
              {
                  strUpdateSQL += ",QT_Z_PD='" + model.QT_Z_PD.Replace("'","''") + "'";
              }

              if(model.Changed("IsUpload") == true)
              {
                  strUpdateSQL += ",IsUpload=" + model.IsUpload + "";
              }

              if(model.Changed("IsAudit") == true)
              {
                  strUpdateSQL += ",IsAudit=" + model.IsAudit + "";
              }

              if(model.Changed("IsPrint") == true)
              {
                  strUpdateSQL += ",IsPrint=" + model.IsPrint + "";
              }

              if(model.Changed("DOWNLINEDATE") == true)
              {
                  strUpdateSQL += ",DOWNLINEDATE='" + model.DOWNLINEDATE.Replace("'","''") + "'";
              }

              if(model.Changed("JYLB_TYPE") == true)
              {
                  strUpdateSQL += ",JYLB_TYPE='" + model.JYLB_TYPE.Replace("'","''") + "'";
              }

              if(model.Changed("CLSXSJ") == true)
              {
                  strUpdateSQL += ",CLSXSJ='" + model.CLSXSJ.Replace("'","''") + "'";
              }

              if(model.Changed("YCY") == true)
              {
                  strUpdateSQL += ",YCY='" + model.YCY.Replace("'","''") + "'";
              }

              if(model.Changed("JCRQ") == true)
              {
                  strUpdateSQL += ",JCRQ='" + model.JCRQ.Replace("'","''") + "'";
              }

               string strSql = "";
               strSql += "update RESULT_DOWNLINE set ";
               strSql += strUpdateSQL.Substring(1);
               strSql += " where ";
               strSql += " JCLSH='"+ strJCLSH +"'";

               return strSql;
          }

          /// <summary>
          /// 修改一条数据
          /// </summary>
          public bool Update(RESULT_DOWNLINE model, string strJCLSH)
          {
              return DbHelper.ExecuteSql(UpdateSQL(model, strJCLSH));
          }

          /// <summary>
          /// 修改一个集合 SQL
          /// </summary>
           public string UpdateRangeSQL(RESULT_DOWNLINE model, string p_strWhere)
          {
               string strUpdateSQL = "";

               if(model.Changed("ID") == true)
               {
                  strUpdateSQL += ",ID=" + model.ID + "";
               }

               if(model.Changed("JCLSH") == true)
               {
                  strUpdateSQL += ",JCLSH='" + model.JCLSH.Replace("'","''") + "'";
               }

               if(model.Changed("WQLSH") == true)
               {
                  strUpdateSQL += ",WQLSH='" + model.WQLSH.Replace("'","''") + "'";
               }

               if(model.Changed("AJLSH") == true)
               {
                  strUpdateSQL += ",AJLSH='" + model.AJLSH.Replace("'","''") + "'";
               }

               if(model.Changed("ZJLSH") == true)
               {
                  strUpdateSQL += ",ZJLSH='" + model.ZJLSH.Replace("'","''") + "'";
               }

               if(model.Changed("MTLSH") == true)
               {
                  strUpdateSQL += ",MTLSH='" + model.MTLSH.Replace("'","''") + "'";
               }

               if(model.Changed("JCBGDBH01") == true)
               {
                  strUpdateSQL += ",JCBGDBH01='" + model.JCBGDBH01.Replace("'","''") + "'";
               }

               if(model.Changed("JCBGDBH02") == true)
               {
                  strUpdateSQL += ",JCBGDBH02='" + model.JCBGDBH02.Replace("'","''") + "'";
               }

               if(model.Changed("JCCS") == true)
               {
                  strUpdateSQL += ",JCCS='" + model.JCCS.Replace("'","''") + "'";
               }

               if(model.Changed("HPHM") == true)
               {
                  strUpdateSQL += ",HPHM='" + model.HPHM.Replace("'","''") + "'";
               }

               if(model.Changed("HPZL") == true)
               {
                  strUpdateSQL += ",HPZL='" + model.HPZL.Replace("'","''") + "'";
               }

               if(model.Changed("HPZLDH") == true)
               {
                  strUpdateSQL += ",HPZLDH='" + model.HPZLDH.Replace("'","''") + "'";
               }

               if(model.Changed("VIN") == true)
               {
                  strUpdateSQL += ",VIN='" + model.VIN.Replace("'","''") + "'";
               }

               if(model.Changed("CLZL") == true)
               {
                  strUpdateSQL += ",CLZL='" + model.CLZL.Replace("'","''") + "'";
               }

               if(model.Changed("CLZLDH") == true)
               {
                  strUpdateSQL += ",CLZLDH='" + model.CLZLDH.Replace("'","''") + "'";
               }

               if(model.Changed("JYLB") == true)
               {
                  strUpdateSQL += ",JYLB='" + model.JYLB.Replace("'","''") + "'";
               }

               if(model.Changed("JYLBDH") == true)
               {
                  strUpdateSQL += ",JYLBDH='" + model.JYLBDH.Replace("'","''") + "'";
               }

               if(model.Changed("YWLX") == true)
               {
                  strUpdateSQL += ",YWLX='" + model.YWLX.Replace("'","''") + "'";
               }

               if(model.Changed("ZYWLB") == true)
               {
                  strUpdateSQL += ",ZYWLB='" + model.ZYWLB.Replace("'","''") + "'";
               }

               if(model.Changed("ZYWLBDH") == true)
               {
                  strUpdateSQL += ",ZYWLBDH='" + model.ZYWLBDH.Replace("'","''") + "'";
               }

               if(model.Changed("SYR") == true)
               {
                  strUpdateSQL += ",SYR='" + model.SYR.Replace("'","''") + "'";
               }

               if(model.Changed("JCXH") == true)
               {
                  strUpdateSQL += ",JCXH=" + model.JCXH + "";
               }

               if(model.Changed("Z_PD") == true)
               {
                  strUpdateSQL += ",Z_PD='" + model.Z_PD.Replace("'","''") + "'";
               }

               if(model.Changed("AJ_Z_PD") == true)
               {
                  strUpdateSQL += ",AJ_Z_PD='" + model.AJ_Z_PD.Replace("'","''") + "'";
               }

               if(model.Changed("ZJ_Z_PD") == true)
               {
                  strUpdateSQL += ",ZJ_Z_PD='" + model.ZJ_Z_PD.Replace("'","''") + "'";
               }

               if(model.Changed("WQ_Z_PD") == true)
               {
                  strUpdateSQL += ",WQ_Z_PD='" + model.WQ_Z_PD.Replace("'","''") + "'";
               }

               if(model.Changed("QT_Z_PD") == true)
               {
                  strUpdateSQL += ",QT_Z_PD='" + model.QT_Z_PD.Replace("'","''") + "'";
               }

               if(model.Changed("IsUpload") == true)
               {
                  strUpdateSQL += ",IsUpload=" + model.IsUpload + "";
               }

               if(model.Changed("IsAudit") == true)
               {
                  strUpdateSQL += ",IsAudit=" + model.IsAudit + "";
               }

               if(model.Changed("IsPrint") == true)
               {
                  strUpdateSQL += ",IsPrint=" + model.IsPrint + "";
               }

               if(model.Changed("DOWNLINEDATE") == true)
               {
                  strUpdateSQL += ",DOWNLINEDATE='" + model.DOWNLINEDATE.Replace("'","''") + "'";
               }

               if(model.Changed("JYLB_TYPE") == true)
               {
                  strUpdateSQL += ",JYLB_TYPE='" + model.JYLB_TYPE.Replace("'","''") + "'";
               }

               if(model.Changed("CLSXSJ") == true)
               {
                  strUpdateSQL += ",CLSXSJ='" + model.CLSXSJ.Replace("'","''") + "'";
               }

               if(model.Changed("YCY") == true)
               {
                  strUpdateSQL += ",YCY='" + model.YCY.Replace("'","''") + "'";
               }

               if(model.Changed("JCRQ") == true)
               {
                  strUpdateSQL += ",JCRQ='" + model.JCRQ.Replace("'","''") + "'";
               }

              string strSql = "";
              strSql += "update RESULT_DOWNLINE set ";
              strSql += strUpdateSQL.Substring(1);
              strSql += " where " + p_strWhere;

              return strSql;
          }

          /// <summary>
          /// 修改一个集合
          /// </summary>
          public bool UpdateRange(RESULT_DOWNLINE model, string p_strWhere)
          {
              return DbHelper.ExecuteSql(UpdateRangeSQL(model, p_strWhere));
          }

          /// <summary>
          /// 修改全部数据 SQL
          /// </summary>
          public string UpdateAllSQL(RESULT_DOWNLINE model)
          {
              string strUpdateSQL = "";

                  strUpdateSQL += ",ID=" + model.ID + "";
                  strUpdateSQL += ",JCLSH='" + model.JCLSH.Replace("'","''") + "'";
                  strUpdateSQL += ",WQLSH='" + model.WQLSH.Replace("'","''") + "'";
                  strUpdateSQL += ",AJLSH='" + model.AJLSH.Replace("'","''") + "'";
                  strUpdateSQL += ",ZJLSH='" + model.ZJLSH.Replace("'","''") + "'";
                  strUpdateSQL += ",MTLSH='" + model.MTLSH.Replace("'","''") + "'";
                  strUpdateSQL += ",JCBGDBH01='" + model.JCBGDBH01.Replace("'","''") + "'";
                  strUpdateSQL += ",JCBGDBH02='" + model.JCBGDBH02.Replace("'","''") + "'";
                  strUpdateSQL += ",JCCS='" + model.JCCS.Replace("'","''") + "'";
                  strUpdateSQL += ",HPHM='" + model.HPHM.Replace("'","''") + "'";
                  strUpdateSQL += ",HPZL='" + model.HPZL.Replace("'","''") + "'";
                  strUpdateSQL += ",HPZLDH='" + model.HPZLDH.Replace("'","''") + "'";
                  strUpdateSQL += ",VIN='" + model.VIN.Replace("'","''") + "'";
                  strUpdateSQL += ",CLZL='" + model.CLZL.Replace("'","''") + "'";
                  strUpdateSQL += ",CLZLDH='" + model.CLZLDH.Replace("'","''") + "'";
                  strUpdateSQL += ",JYLB='" + model.JYLB.Replace("'","''") + "'";
                  strUpdateSQL += ",JYLBDH='" + model.JYLBDH.Replace("'","''") + "'";
                  strUpdateSQL += ",YWLX='" + model.YWLX.Replace("'","''") + "'";
                  strUpdateSQL += ",ZYWLB='" + model.ZYWLB.Replace("'","''") + "'";
                  strUpdateSQL += ",ZYWLBDH='" + model.ZYWLBDH.Replace("'","''") + "'";
                  strUpdateSQL += ",SYR='" + model.SYR.Replace("'","''") + "'";
                  strUpdateSQL += ",JCXH=" + model.JCXH + "";
                  strUpdateSQL += ",Z_PD='" + model.Z_PD.Replace("'","''") + "'";
                  strUpdateSQL += ",AJ_Z_PD='" + model.AJ_Z_PD.Replace("'","''") + "'";
                  strUpdateSQL += ",ZJ_Z_PD='" + model.ZJ_Z_PD.Replace("'","''") + "'";
                  strUpdateSQL += ",WQ_Z_PD='" + model.WQ_Z_PD.Replace("'","''") + "'";
                  strUpdateSQL += ",QT_Z_PD='" + model.QT_Z_PD.Replace("'","''") + "'";
                  strUpdateSQL += ",IsUpload=" + model.IsUpload + "";
                  strUpdateSQL += ",IsAudit=" + model.IsAudit + "";
                  strUpdateSQL += ",IsPrint=" + model.IsPrint + "";
                  strUpdateSQL += ",DOWNLINEDATE='" + model.DOWNLINEDATE.Replace("'","''") + "'";
                  strUpdateSQL += ",JYLB_TYPE='" + model.JYLB_TYPE.Replace("'","''") + "'";
                  strUpdateSQL += ",CLSXSJ='" + model.CLSXSJ.Replace("'","''") + "'";
                  strUpdateSQL += ",YCY='" + model.YCY.Replace("'","''") + "'";
                  strUpdateSQL += ",JCRQ='" + model.JCRQ.Replace("'","''") + "'";


               string strSql = "";
               strSql += "update RESULT_DOWNLINE set ";
               strSql += strUpdateSQL.Substring(1);

               return strSql;

          }

          /// <summary>
          /// 修改全部数据
          /// </summary>
          public bool UpdateAll(RESULT_DOWNLINE model)
          {
              return DbHelper.ExecuteSql(UpdateAllSQL(model));
          }

          /// <summary>
          /// 删除一条数据 SQL
          /// </summary>
          public string DeleteSQL(string strJCLSH)
          {
              string strSql = "";
              strSql += "delete from RESULT_DOWNLINE";
              strSql += " where ";
               strSql += " JCLSH='"+ strJCLSH +"'";

              return strSql;

          }

          /// <summary>
          /// 删除一条数据
          /// </summary>
          public bool Delete(string strJCLSH)
          {
              return DbHelper.ExecuteSql(DeleteSQL(strJCLSH));
          }

          /// <summary>
          /// 删除一个集合 SQL
          /// </summary>
          public string DeleteRangeSQL(string p_strWhere)
          {
              string strSql = "";
              strSql += "delete from RESULT_DOWNLINE";
              strSql += " where " + p_strWhere;

              return strSql;
           }

          /// <summary>
          /// 删除一个集合
          /// </summary>
          public bool DeleteRange(string p_strWhere)
          {
              return DbHelper.ExecuteSql(DeleteRangeSQL(p_strWhere));
          }

          /// <summary>
          /// 删除全部 SQL
          /// </summary>
          public string DeleteAllSQL()
          {
              string strSql = "";
              strSql += "delete from RESULT_DOWNLINE";

              return strSql;
           }

         /// <summary>
         /// 删除全部
         /// </summary>
         public bool DeleteAll()
         {
             return DbHelper.ExecuteSql(DeleteAllSQL());
         }

          /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public RESULT_DOWNLINE GetModel(string strJCLSH)
         {
             string strSql = "";
             strSql += "select * from RESULT_DOWNLINE";
             strSql += " where ";
               strSql += " JCLSH='"+ strJCLSH +"'";

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             RESULT_DOWNLINE model = new RESULT_DOWNLINE();

             if(dtTemp.Rows.Count>0)
             {
                 model = new RESULT_DOWNLINE();

                 model.ID = dtTemp.Rows[0]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["ID"]);
                 model.JCLSH = dtTemp.Rows[0]["JCLSH"] == DBNull.Value ? "" : dtTemp.Rows[0]["JCLSH"].ToString();
                 model.WQLSH = dtTemp.Rows[0]["WQLSH"] == DBNull.Value ? "" : dtTemp.Rows[0]["WQLSH"].ToString();
                 model.AJLSH = dtTemp.Rows[0]["AJLSH"] == DBNull.Value ? "" : dtTemp.Rows[0]["AJLSH"].ToString();
                 model.ZJLSH = dtTemp.Rows[0]["ZJLSH"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZJLSH"].ToString();
                 model.MTLSH = dtTemp.Rows[0]["MTLSH"] == DBNull.Value ? "" : dtTemp.Rows[0]["MTLSH"].ToString();
                 model.JCBGDBH01 = dtTemp.Rows[0]["JCBGDBH01"] == DBNull.Value ? "" : dtTemp.Rows[0]["JCBGDBH01"].ToString();
                 model.JCBGDBH02 = dtTemp.Rows[0]["JCBGDBH02"] == DBNull.Value ? "" : dtTemp.Rows[0]["JCBGDBH02"].ToString();
                 model.JCCS = dtTemp.Rows[0]["JCCS"] == DBNull.Value ? "" : dtTemp.Rows[0]["JCCS"].ToString();
                 model.HPHM = dtTemp.Rows[0]["HPHM"] == DBNull.Value ? "" : dtTemp.Rows[0]["HPHM"].ToString();
                 model.HPZL = dtTemp.Rows[0]["HPZL"] == DBNull.Value ? "" : dtTemp.Rows[0]["HPZL"].ToString();
                 model.HPZLDH = dtTemp.Rows[0]["HPZLDH"] == DBNull.Value ? "" : dtTemp.Rows[0]["HPZLDH"].ToString();
                 model.VIN = dtTemp.Rows[0]["VIN"] == DBNull.Value ? "" : dtTemp.Rows[0]["VIN"].ToString();
                 model.CLZL = dtTemp.Rows[0]["CLZL"] == DBNull.Value ? "" : dtTemp.Rows[0]["CLZL"].ToString();
                 model.CLZLDH = dtTemp.Rows[0]["CLZLDH"] == DBNull.Value ? "" : dtTemp.Rows[0]["CLZLDH"].ToString();
                 model.JYLB = dtTemp.Rows[0]["JYLB"] == DBNull.Value ? "" : dtTemp.Rows[0]["JYLB"].ToString();
                 model.JYLBDH = dtTemp.Rows[0]["JYLBDH"] == DBNull.Value ? "" : dtTemp.Rows[0]["JYLBDH"].ToString();
                 model.YWLX = dtTemp.Rows[0]["YWLX"] == DBNull.Value ? "" : dtTemp.Rows[0]["YWLX"].ToString();
                 model.ZYWLB = dtTemp.Rows[0]["ZYWLB"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZYWLB"].ToString();
                 model.ZYWLBDH = dtTemp.Rows[0]["ZYWLBDH"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZYWLBDH"].ToString();
                 model.SYR = dtTemp.Rows[0]["SYR"] == DBNull.Value ? "" : dtTemp.Rows[0]["SYR"].ToString();
                 model.JCXH = dtTemp.Rows[0]["JCXH"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["JCXH"]);
                 model.Z_PD = dtTemp.Rows[0]["Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[0]["Z_PD"].ToString();
                 model.AJ_Z_PD = dtTemp.Rows[0]["AJ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[0]["AJ_Z_PD"].ToString();
                 model.ZJ_Z_PD = dtTemp.Rows[0]["ZJ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZJ_Z_PD"].ToString();
                 model.WQ_Z_PD = dtTemp.Rows[0]["WQ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[0]["WQ_Z_PD"].ToString();
                 model.QT_Z_PD = dtTemp.Rows[0]["QT_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[0]["QT_Z_PD"].ToString();
                 model.IsUpload = dtTemp.Rows[0]["IsUpload"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["IsUpload"]);
                 model.IsAudit = dtTemp.Rows[0]["IsAudit"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["IsAudit"]);
                 model.IsPrint = dtTemp.Rows[0]["IsPrint"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["IsPrint"]);
                 model.DOWNLINEDATE = dtTemp.Rows[0]["DOWNLINEDATE"] == DBNull.Value ? "" : dtTemp.Rows[0]["DOWNLINEDATE"].ToString();
                 model.JYLB_TYPE = dtTemp.Rows[0]["JYLB_TYPE"] == DBNull.Value ? "" : dtTemp.Rows[0]["JYLB_TYPE"].ToString();
                 model.CLSXSJ = dtTemp.Rows[0]["CLSXSJ"] == DBNull.Value ? "" : dtTemp.Rows[0]["CLSXSJ"].ToString();
                 model.YCY = dtTemp.Rows[0]["YCY"] == DBNull.Value ? "" : dtTemp.Rows[0]["YCY"].ToString();
                 model.JCRQ = dtTemp.Rows[0]["JCRQ"] == DBNull.Value ? "" : dtTemp.Rows[0]["JCRQ"].ToString();
             }

             dtTemp.Dispose();

             return model;
         }

         /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public void GetModel(ref DataTable p_dtData, string strJCLSH)
         {
             p_dtData.Clear();

             string strSql = "";
             strSql += "select * from RESULT_DOWNLINE";
             strSql += " where ";
               strSql += " JCLSH='"+ strJCLSH +"'";

              DbHelper.GetTable(strSql, ref p_dtData);
         }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList(string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
               m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
               m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
               m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from RESULT_DOWNLINE";
          if(p_strWhere.Trim().Length > 0)
          {
               strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
               strSql += " order by " + p_strOrder;
          }

          DataTable dtTemp = new DataTable();

          if(p_intPageSize > 0)
          {
               DbHelper.GetTable(strSql, ref dtTemp, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
               DbHelper.GetTable(strSql, ref dtTemp);
          }

          RESULT_DOWNLINE[] arrModel=new RESULT_DOWNLINE[dtTemp.Rows.Count];

          for(int N=0;N<dtTemp.Rows.Count;N++)
          {
               arrModel[N] = new RESULT_DOWNLINE();

                 arrModel[N].ID = dtTemp.Rows[N]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["ID"]);
                 arrModel[N].JCLSH = dtTemp.Rows[N]["JCLSH"] == DBNull.Value ? "" : dtTemp.Rows[N]["JCLSH"].ToString();
                 arrModel[N].WQLSH = dtTemp.Rows[N]["WQLSH"] == DBNull.Value ? "" : dtTemp.Rows[N]["WQLSH"].ToString();
                 arrModel[N].AJLSH = dtTemp.Rows[N]["AJLSH"] == DBNull.Value ? "" : dtTemp.Rows[N]["AJLSH"].ToString();
                 arrModel[N].ZJLSH = dtTemp.Rows[N]["ZJLSH"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZJLSH"].ToString();
                 arrModel[N].MTLSH = dtTemp.Rows[N]["MTLSH"] == DBNull.Value ? "" : dtTemp.Rows[N]["MTLSH"].ToString();
                 arrModel[N].JCBGDBH01 = dtTemp.Rows[N]["JCBGDBH01"] == DBNull.Value ? "" : dtTemp.Rows[N]["JCBGDBH01"].ToString();
                 arrModel[N].JCBGDBH02 = dtTemp.Rows[N]["JCBGDBH02"] == DBNull.Value ? "" : dtTemp.Rows[N]["JCBGDBH02"].ToString();
                 arrModel[N].JCCS = dtTemp.Rows[N]["JCCS"] == DBNull.Value ? "" : dtTemp.Rows[N]["JCCS"].ToString();
                 arrModel[N].HPHM = dtTemp.Rows[N]["HPHM"] == DBNull.Value ? "" : dtTemp.Rows[N]["HPHM"].ToString();
                 arrModel[N].HPZL = dtTemp.Rows[N]["HPZL"] == DBNull.Value ? "" : dtTemp.Rows[N]["HPZL"].ToString();
                 arrModel[N].HPZLDH = dtTemp.Rows[N]["HPZLDH"] == DBNull.Value ? "" : dtTemp.Rows[N]["HPZLDH"].ToString();
                 arrModel[N].VIN = dtTemp.Rows[N]["VIN"] == DBNull.Value ? "" : dtTemp.Rows[N]["VIN"].ToString();
                 arrModel[N].CLZL = dtTemp.Rows[N]["CLZL"] == DBNull.Value ? "" : dtTemp.Rows[N]["CLZL"].ToString();
                 arrModel[N].CLZLDH = dtTemp.Rows[N]["CLZLDH"] == DBNull.Value ? "" : dtTemp.Rows[N]["CLZLDH"].ToString();
                 arrModel[N].JYLB = dtTemp.Rows[N]["JYLB"] == DBNull.Value ? "" : dtTemp.Rows[N]["JYLB"].ToString();
                 arrModel[N].JYLBDH = dtTemp.Rows[N]["JYLBDH"] == DBNull.Value ? "" : dtTemp.Rows[N]["JYLBDH"].ToString();
                 arrModel[N].YWLX = dtTemp.Rows[N]["YWLX"] == DBNull.Value ? "" : dtTemp.Rows[N]["YWLX"].ToString();
                 arrModel[N].ZYWLB = dtTemp.Rows[N]["ZYWLB"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZYWLB"].ToString();
                 arrModel[N].ZYWLBDH = dtTemp.Rows[N]["ZYWLBDH"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZYWLBDH"].ToString();
                 arrModel[N].SYR = dtTemp.Rows[N]["SYR"] == DBNull.Value ? "" : dtTemp.Rows[N]["SYR"].ToString();
                 arrModel[N].JCXH = dtTemp.Rows[N]["JCXH"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["JCXH"]);
                 arrModel[N].Z_PD = dtTemp.Rows[N]["Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[N]["Z_PD"].ToString();
                 arrModel[N].AJ_Z_PD = dtTemp.Rows[N]["AJ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[N]["AJ_Z_PD"].ToString();
                 arrModel[N].ZJ_Z_PD = dtTemp.Rows[N]["ZJ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZJ_Z_PD"].ToString();
                 arrModel[N].WQ_Z_PD = dtTemp.Rows[N]["WQ_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[N]["WQ_Z_PD"].ToString();
                 arrModel[N].QT_Z_PD = dtTemp.Rows[N]["QT_Z_PD"] == DBNull.Value ? "" : dtTemp.Rows[N]["QT_Z_PD"].ToString();
                 arrModel[N].IsUpload = dtTemp.Rows[N]["IsUpload"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["IsUpload"]);
                 arrModel[N].IsAudit = dtTemp.Rows[N]["IsAudit"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["IsAudit"]);
                 arrModel[N].IsPrint = dtTemp.Rows[N]["IsPrint"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["IsPrint"]);
                 arrModel[N].DOWNLINEDATE = dtTemp.Rows[N]["DOWNLINEDATE"] == DBNull.Value ? "" : dtTemp.Rows[N]["DOWNLINEDATE"].ToString();
                 arrModel[N].JYLB_TYPE = dtTemp.Rows[N]["JYLB_TYPE"] == DBNull.Value ? "" : dtTemp.Rows[N]["JYLB_TYPE"].ToString();
                 arrModel[N].CLSXSJ = dtTemp.Rows[N]["CLSXSJ"] == DBNull.Value ? "" : dtTemp.Rows[N]["CLSXSJ"].ToString();
                 arrModel[N].YCY = dtTemp.Rows[N]["YCY"] == DBNull.Value ? "" : dtTemp.Rows[N]["YCY"].ToString();
                 arrModel[N].JCRQ = dtTemp.Rows[N]["JCRQ"] == DBNull.Value ? "" : dtTemp.Rows[N]["JCRQ"].ToString();
          }

          dtTemp.Dispose();

          return arrModel;
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList(string p_strWhere)
      {
          return GetModelList(p_strWhere, "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList(string p_strWhere, string p_strOrder)
      {
          return GetModelList(p_strWhere, p_strOrder, -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList(int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList("", "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList(string p_strWhere, int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList(p_strWhere, "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public RESULT_DOWNLINE[] GetModelList()
      {
          return GetModelList("", "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          p_dtData.Clear();

          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
              m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
              m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
              m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from RESULT_DOWNLINE";
          if(p_strWhere.Trim().Length > 0)
          {
              strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
              strSql += " order by " + p_strOrder;
          }

          if(p_intPageSize > 0)
          {
              DbHelper.GetTable(strSql, ref p_dtData, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
              DbHelper.GetTable(strSql, ref p_dtData);
          }
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere)
       {
           GetModelList(ref p_dtData, p_strWhere, "", -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder)
       {
           GetModelList(ref p_dtData, p_strWhere, p_strOrder, -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, "", "", p_intPageNumber, p_intPageSize);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, p_strWhere, "", p_intPageNumber, p_intPageSize);
       }
       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData)
       {
           GetModelList(ref p_dtData, "", "", -1, -1);
       }
   }
}
